package fr.mywiki.business.versioning.diff;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import fr.mywiki.business.utils.StringUtils;

/** Tests VersionDiff class */
public class VersionDiffTest extends TestCase {
	public VersionDiffTest(String a_name) {
		super(a_name);
	}

	public static Test suite() {
		TestSuite suite = new TestSuite();
		suite.addTestSuite(VersionDiffTest.class);

		return suite;
	}
	public void testVersionDiff() {
		test("abcde", "abcdg");
		test("abcdef","bcgheij");
		test("abcde","fgabchdeij");
		test("abcde","fgabchde");
		test("abcde","bd");
		
		test("abcd","");
		test("abcde","habcdfe");
		test("abcde","habce");
		test("abcde","habcfe");
		
		test("abcde","bcfe");
		test("abcde","bce");
		test("abcde","bcfe");
		
		test("abcde","fbcdhe");
		test("abcde","fbcde");
		test("abcde","fbche");
	}
	
	private void test(String from, String to) {
		VersionDiff vd = new VersionDiff(new Diff(StringUtils.toStringArray(from),
				StringUtils.toStringArray(to)), to);
		
		assertEquals(to,vd.getString(from));
	}
}
